/**
 * User: dizemding
 * Time: 11-7-19 下午2:04
 */

/**
 * 重置验证码
 * @param img 验证码图片
 */
function resetValidationCode(img) {
	img.click()
}

function formatFloat(src, pos) {
	return Math.round(src * Math.pow(10, pos)) / Math.pow(10, pos);
}

/**
 * 警告框提示
 * @param message 提示内容
 * @param title 提示标题
 */
function alert(message, title) {
	if (title == null) {
		title = "提示";
	}
	if ($("#dialogalert").length == 0) {
		$("body").append('<div id="dialogalert"></div>');
		$("#dialogalert").dialog({
			autoOpen: false,
			title: title,
			modal: true,
			resizable:false,
			show: "clip",
			hide: "slide",
			buttons: {
				"确定": function() {
					$(this).dialog("close");
				}
			}
		});
	}

	$("#dialogalert").html(message);
	$("#dialogalert").dialog("open");
}

/**
 * 确认框提示
 * @param message
 * @param title
 * @param callback
 */
function confirm(message, title, callback) {
	if ($("#dialogconfirm").length == 0) {
		$("body").append('<div id="dialogconfirm" title="提示"></div>');
		$("#dialogconfirm").dialog({
			autoOpen: false,
			title: title,
			modal: true,
			resizable:false,
			show: "clip",
			hide: "slide",
			buttons: {
				"确定": function() {
					callback();
					$(this).dialog("close");
				},
				"取消": function() {
					$(this).dialog("close");
				}
			}
		});
	}
	$("#dialogconfirm").html(message);
	$("#dialogconfirm").dialog("open");
}

function confirmDelete(msg, url) {
	confirm(msg, '确认删除', function() {
		window.location.href = url;
	});
	return false;
}

function confirmOrder(msg, url) {
	confirm(msg, '操作', function() {
		window.location.href = url;
	});
	return false;
}